package com.thoughtworks.studentManagement.controller;

import com.thoughtworks.studentManagement.model.Student;
import com.thoughtworks.studentManagement.service.StudentService;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
class StudentController {

    private final StudentService service;

    StudentController(StudentService service) {
        this.service = service;
    }

    @GetMapping("/students")
    @ResponseStatus(value = HttpStatus.OK)
    List<Student> getAllStudents() {
        return service.findAllStudents();
    }

    @GetMapping("/students/{studentNumber}")
    Student getOneStudent(@PathVariable String studentNumber) {
        return service.findAStudent(studentNumber);
    }
}
